home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Frame;
- import java.awt.Rectangle;
-
- public class QuitDialog extends Dialog {
- Button yesButton;
- Button noButton;
-
- void yesButton_Clicked(Event event) {
- ((Component)this).getParent().handleEvent(new Event(this, 201, (Object)null));
- }
-
- void noButton_Clicked(Event event) {
- ((Component)this).hide();
- }
-
- public QuitDialog(Frame parent, boolean modal) {
- super(parent, modal);
- ((Container)this).setLayout(new FlowLayout(1, 20, 20));
- ((Dialog)this).addNotify();
- ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 295, ((Container)this).insets().top + ((Container)this).insets().bottom + 92);
- this.yesButton = new Button("Yes");
- this.yesButton.reshape(((Container)this).insets().left + 51, ((Container)this).insets().top + 20, 60, 40);
- ((Container)this).add(this.yesButton);
- this.noButton = new Button("No");
- this.noButton.reshape(((Container)this).insets().left + 165, ((Container)this).insets().top + 20, 60, 40);
- ((Container)this).add(this.noButton);
- ((Dialog)this).setResizable(false);
- }
-
- public QuitDialog(Frame parent, String title, boolean modal) {
- this(parent, modal);
- ((Dialog)this).setTitle(title);
- }
-
- public synchronized void show() {
- Rectangle bounds = ((Component)this).getParent().bounds();
- Rectangle abounds = ((Component)this).bounds();
- ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if (event.id == 201) {
- ((Component)this).hide();
- return true;
- } else {
- if (event.target == this.noButton && event.id == 1001) {
- this.noButton_Clicked(event);
- }
-
- if (event.target == this.yesButton && event.id == 1001) {
- this.yesButton_Clicked(event);
- }
-
- return super.handleEvent(event);
- }
- }
- }
-